<?php

/**
 * This is the model class for table "product_shop".
 *
 * The followings are the available columns in table 'product_shop':
 * @property string $id
 * @property string $title
 * @property string $code
 * @property double $price
 * @property double $promotional_price
 * @property string $short_content
 * @property string $detailed_content
 * @property string $counter
 * @property integer $hot
 * @property integer $activated_flag
 * @property string $images
 * @property string $file_download
 * @property integer $type_id
 * @property string $folder_id
 * @property string $insert_by
 * @property string $update_by
 * @property string $insert_time
 * @property string $update_time
 */
class ProductShop extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ProductShop the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'product_shop';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('title, code, short_content, detailed_content, counter, images, file_download, type_id', 'required'),
			array('hot, activated_flag, type_id', 'numerical', 'integerOnly'=>true),
			array('price, promotional_price', 'numerical'),
			array('title, code, images, file_download', 'length', 'max'=>255),
			array('folder_id', 'length', 'max'=>13),
			array('counter', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, title, code, price, promotional_price, short_content, detailed_content, counter, hot, activated_flag, images, file_download, type_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'title' => 'Title',
			'code' => 'Code',
			'price' => 'Price',
			'promotional_price' => 'Promotional Price',
			'short_content' => 'Short Content',
			'detailed_content' => 'Detailed Content',
			'counter' => 'Counter',
			'hot' => 'Hot',
			'activated_flag' => 'Activated Flag',
			'images' => 'Images',
			'file_download' => 'File Download',
			'type_id' => 'Type',
			'folder_id' => 'Folder ID',
			'insert_by' => 'Insert By',
			'update_by' => 'Update By',
			'insert_time' => 'Insert Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('code',$this->code,true);
		$criteria->compare('price',$this->price);
		$criteria->compare('promotional_price',$this->promotional_price);
		$criteria->compare('short_content',$this->short_content,true);
		$criteria->compare('detailed_content',$this->detailed_content,true);
		$criteria->compare('counter',$this->counter,true);
		$criteria->compare('hot',$this->hot);
		$criteria->compare('activated_flag',$this->activated_flag);
		$criteria->compare('images',$this->images,true);
		$criteria->compare('file_download',$this->file_download,true);
		$criteria->compare('type_id',$this->type_id);
		$criteria->compare('insert_by',$this->insert_by,true);
		$criteria->compare('update_by',$this->update_by,true);
		$criteria->compare('insert_time',$this->insert_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}